//
//  AppDelegate.m
//  vmcshop
//
//  Created by bigknife on 14-10-8.
//  Copyright (c) 2012年 idongler. All rights reserved.
//

#import "AppDelegate.h"
#import "UMSocial.h"
#import "UMSocialWechatHandler.h"
#import "BPush.h"
#import "VMCIndexApi.h"
#import "NTViewController.h"


//#import "VMCMemberCenterModuleViewController.h"
//#import "VMCCategoryContainerViewController.h"
@interface AppDelegate (){
	NSString * msgId;
}

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [UIWindow new];
    [self.window makeKeyAndVisible];
    self.window.frame = [[UIScreen mainScreen]bounds];
	self.window.backgroundColor = [UIColor whiteColor];
	
	NTViewController * ntViewController = [[NTViewController alloc]init];
//	[self setupUnreadCount];
	self.window.rootViewController = ntViewController;
	//监听网络状态
	[self searchNetworkStatus];
	//注册第三方分享
	[self registShareKit];


	return YES;
}

- (void)testLocalNotifi
{
	NSLog(@"测试本地通知啦！！！");
	NSDate *fireDate = [[NSDate new] dateByAddingTimeInterval:5];
	[BPush localNotification:fireDate alertBody:@"这是本地通知" badge:3 withFirstAction:@"打开" withSecondAction:@"关闭" userInfo:nil soundName:nil region:nil regionTriggersOnce:YES category:nil];
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
	// 打印到日志 textView 中
	
}

// 在 iOS8 系统中，还需要添加这个方法。通过新的 API 注册推送服务
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{

	[application registerForRemoteNotifications];
	
	
}

- (void)searchNetworkStatus
{
	[[AFNetworkReachabilityManager sharedManager] startMonitoring];

	// 检测网络连接的单例,网络变化时的回调方法
	[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status)
	 {
		NSLog(@"%ld", (long)status);
	}];
}

- (void)registShareKit
{
	//友盟注册
	[UMSocialData setAppKey:@"55e513dee0f55ad237001a20"];
	[UMSocialWechatHandler setWXAppId:@"wx91bc4ceb299e1243" appSecret:@"d487d5eb05330761ba2aabd6b57b43f3" url:nil];

}



- (void)onGetNetworkState:(int)iError
{
	if (0 == iError) {
		NSLog(@"联网成功");
	}
	else{
		NSLog(@"onGetNetworkState %d",iError);
	}

}

- (void)onGetPermissionState:(int)iError
{
	if (0 == iError)
	{
		NSLog(@"授权成功");
	}
	else
	{
		NSLog(@"onGetPermissionState %d",iError);
	}
}

@end
